package org.cycuchy.hp.service {
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	
	public class ServiceHelper {

		public static function invokeMethod(service:CHService, completeCallback:Function, progressCallback:Function, ioErrorCallback:Function, method:String, ...params:Array):void {
//			trace("invokeMethod");
			var loader:URLLoader = service.urlLoader;
			loader.addEventListener(Event.COMPLETE, completeCallback);
			loader.addEventListener(ProgressEvent.PROGRESS, progressCallback);
			loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorCallback);
			loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityErrorCallback);
			loader.load(new URLRequest(method));		
		}
		
		private static function onSecurityErrorCallback(event:SecurityErrorEvent):void {
//			trace("onSecurityErrorCallback");
		}

	}
	
}